home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / gchess40.lha / gnuchess4.0p62 / src / uxdsp.c < prev    next >
C/C++ Source or Header  |  1993-06-22  |  18KB  |  898 lines

  1. /*
  2.  * uxdsp.c - ALPHA interface for CHESS
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. #include <ctype.h>
  24. #include <signal.h>
  25. #ifdef MSDOS
  26. #include <dos.h>
  27. /*#include <conio.h>*/
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #include <time.h>
  31.  
  32. #define ESC 0x1B
  33. #define refresh() fflush(stdout)
  34.  
  35. static void param (short n);
  36.  
  37. #else
  38. #include <sys/param.h>
  39. #include <sys/types.h>
  40. #include <sys/file.h>
  41. #include <curses.h>
  42.  
  43. #if defined(__STDC__)
  44. /* <stdlib.h> */
  45.      extern void *malloc (size_t);
  46.      extern void exit (int);
  47.  
  48. /* <string.h> */
  49.      extern char *strcat (char *, const char *);
  50.      extern int strcmp (const char *, const char *);
  51.      extern char *strcpy (char *, const char *);
  52.  
  53. /* <time.h> */
  54.      extern long int time (long int *);
  55. #endif
  56.  
  57. #endif /* MSDOS */
  58.  
  59. int mycnt1, mycnt2;
  60. #include "gnuchess.h"
  61.  
  62. extern short int pscore[2];
  63.  
  64. #define TAB (46)
  65. #define VIR_C(s)  ((flag.reverse) ? 7-column(s) : column(s))
  66. #define VIR_R(s)  ((flag.reverse) ? 7-row(s) : row(s))
  67.  
  68. unsigned short int MV[MAXDEPTH];
  69. int MSCORE;
  70. char *DRAW;
  71. extern char mvstr[4][6];
  72.  
  73. void TerminateSearch (int), Die (int);
  74.  
  75. void
  76. Initialize (void)
  77. {
  78.   signal (SIGINT, Die);
  79. #ifndef MSDOS
  80.   signal (SIGQUIT, Die);
  81.   initscr ();
  82.   crmode ();
  83. #else
  84.   mycnt1 = mycnt2 = 0;
  85. #endif /* MSDOS */
  86. }
  87.  
  88. void
  89. ExitChess (void)
  90. {
  91.   ListGame ();
  92.   gotoXY (1, 24);
  93. #ifndef MSDOS
  94.   refresh();
  95.   nocrmode ();
  96.   endwin ();
  97. #endif /* MSDOS */
  98.   exit (0);
  99. }
  100.  
  101. void
  102. Die (int Sig)
  103. {
  104.   char s[80];
  105.  
  106.   signal (SIGINT, SIG_IGN);
  107. #ifdef MSDOS
  108.   Sig++;            /* shut up the compiler */
  109. #else
  110.   signal (SIGQUIT, SIG_IGN);
  111. #endif /* MSDOS */
  112.   ShowMessage (CP[31]);        /*Abort?*/
  113.   scanz ("%s", s);
  114.   if (strcmp (s, CP[210]) == 0)    /*yes*/
  115.     ExitChess ();
  116.   signal (SIGINT, Die);
  117. #ifndef MSDOS
  118.   signal (SIGQUIT, Die);
  119. #endif /* MSDOS */
  120. }
  121.  
  122. void
  123. TerminateSearch (int Sig)
  124. {
  125.   signal (SIGINT, SIG_IGN);
  126. #ifdef MSDOS
  127.   Sig++;            /* shut up the compiler */
  128. #else
  129.   signal (SIGQUIT, SIG_IGN);
  130. #endif /* MSDOS */
  131.   if (!flag.timeout)
  132.     flag.musttimeout = true;
  133.   flag.bothsides = false;
  134.   signal (SIGINT, Die);
  135. #ifndef MSDOS
  136.   signal (SIGQUIT, Die);
  137. #endif /* MSDOS */
  138. }
  139. void
  140. ShowLine (short unsigned int *bstline)
  141. {
  142. }
  143.  
  144. void
  145. help (void)
  146. {
  147.   ClrScreen ();
  148.   /*printz ("CHESS command summary\n");*/
  149.   printz (CP[40]);
  150.   printz ("----------------------------------------------------------------\n");
  151.   /*printz ("g1f3      move from g1 to f3      quit      Exit Chess\n");*/
  152.   printz (CP[158]);
  153.   /*printz ("Nf3       move knight to f3       beep      turn %s\n", (flag.beep) ? "off" : "on");*/
  154.   printz (CP[86], (flag.beep) ? CP[92] : CP[93]);
  155.   /*printz ("a7a8q     promote pawn to queen\n");*/
  156.   printz (CP[128], (flag.material) ? CP[92] : CP[93]);
  157.   /*printz ("o-o       castle king side        easy      turn %s\n", (flag.easy) ? "off" : "on");*/
  158.   printz (CP[173], (flag.easy) ? CP[92] : CP[93]);
  159.   /*printz ("o-o-o     castle queen side       hash      turn %s\n", (flag.hash) ? "off" : "on");*/
  160.   printz (CP[174], (flag.hash) ? CP[92] : CP[93]);
  161.   /*printz ("bd        redraw board            reverse   board display\n");*/
  162.   printz (CP[130]);
  163.   /*printz ("list      game to chess.lst       book      turn %s used %d of %d\n", (Book) ? "off" : "on", book
  164. count, booksize);*/
  165.   printz (CP[170], (Book) ? CP[92] : CP[93], bookcount, BOOKSIZE);
  166.   /*printz ("undo      undo last ply           remove    take back a move\n");*/
  167.   printz (CP[200]);
  168.   /*printz ("edit      edit board              force     enter game moves\n");*/
  169.   printz (CP[153]);
  170.   /*printz ("switch    sides with computer     both      computer match\n");*/
  171.   printz (CP[194]);
  172.   /*printz ("white     computer plays white    black     computer plays black\n");*/
  173.   printz (CP[202]);
  174.   /*printz ("depth     set search depth        clock     set time control\n");*/
  175.   printz (CP[149]);
  176.   /*printz ("hint      suggest a move         post      turn %s principle variation\n", (flag.post) ? "off" :
  177. "on");*/
  178.   printz (CP[177], (flag.post) ? CP[92] : CP[93]);
  179.   /*printz ("save      game to file            get       game from file\n");*/
  180.   printz (CP[188]);
  181.   /*printz ("random    randomize play          new       start new game\n");*/
  182.   printz (CP[181]);
  183.   gotoXY (10, 20);
  184.   printz (CP[47], ColorStr[computer]);
  185.   gotoXY (10, 21);
  186.   printz (CP[97], ColorStr[opponent]);
  187.   gotoXY (10, 22);
  188.   printz (CP[79], MaxResponseTime/100);
  189.   gotoXY (10, 23);
  190.   printz (CP[59], (flag.easy) ? CP[93] : CP[92]);
  191.   gotoXY (40, 20);
  192.   printz (CP[52], MaxSearchDepth);
  193.   gotoXY (40, 21);
  194.   printz (CP[100], (dither) ? CP[93] : CP[92]);
  195.   gotoXY (40, 22);
  196.   printz (CP[112], (flag.hash) ? CP[93] : CP[92]);
  197.   gotoXY (40, 23);
  198.   printz (CP[73]);
  199.   gotoXY (10, 24);
  200.   printz (CP[110], (TCflag) ? CP[93] : CP[92],
  201.       TimeControl.moves[white], TimeControl.clock[white] / 100, OperatorTime, MaxSearchDepth);
  202.   refresh ();
  203. #ifdef BOGUS
  204.   fflush (stdin); /*what is this supposed to do??*/
  205. #endif /*BOGUS*/
  206.   getchar ();
  207.   ClrScreen ();
  208.   UpdateDisplay (0, 0, 1, 0);
  209. }
  210.  
  211.  
  212. void
  213. EditBoard (void)
  214.  
  215. /*
  216.  * Set up a board position. Pieces are entered by typing the piece followed
  217.  * by the location. For example, Nf3 will place a knight on square f3.
  218.  */
  219.  
  220. {
  221.   short a, r, c, sq, i;
  222.   char s[80];
  223.  
  224.   flag.regularstart = true;
  225.   Book = BOOKFAIL;
  226.   ClrScreen ();
  227.   UpdateDisplay (0, 0, 1, 0);
  228.   gotoXY (TAB, 3);
  229.   printz (CP[29]);
  230.   gotoXY (TAB, 4);
  231.   printz (CP[28]);
  232.   gotoXY (TAB, 5);
  233.   printz (CP[136]);
  234.   gotoXY (TAB, 7);
  235.   printz (CP[64]);
  236.   a = white;
  237.   do
  238.     {
  239.       gotoXY (TAB, 6);
  240.       printz (CP[60], ColorStr[a]);    /*Editing %s*/
  241.       gotoXY (TAB + 24, 7);
  242.       ClrEoln ();
  243.       scanz ("%s", s);
  244.       if (s[0] == CP[28][0])    /*#*/
  245.     {
  246.       for (sq = 0; sq < 64; sq++)
  247.         {
  248.           board[sq] = no_piece;
  249.           color[sq] = neutral;
  250.           DrawPiece (sq);
  251.         }
  252.     }
  253.       if (s[0] == CP[136][0])    /*c*/
  254.     a = otherside[a];
  255.       c = s[1] - 'a';
  256.       r = s[2] - '1';
  257.       if ((c >= 0) && (c < 8) && (r >= 0) && (r < 8))
  258.     {
  259.       sq = locn (r, c);
  260.       for (i = king; i > no_piece; i--)
  261.         if ((s[0] == pxx[i]) || (s[0] == qxx[i]))
  262.           break;
  263.       board[sq] = i;
  264.       color[sq] = ((board[sq] == no_piece) ? neutral : a);
  265.       DrawPiece (sq);
  266.     }
  267.   } while (s[0] != CP[29][0]);    /*.*/
  268.  
  269.   for (sq = 0; sq < 64; sq++)
  270.     Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0);
  271.   GameCnt = 0;
  272.   Game50 = 1;
  273.   ZeroRPT ();
  274.   Sdepth = 0;
  275.   InitializeStats ();
  276.   ClrScreen ();
  277.   UpdateDisplay (0, 0, 1, 0);
  278. }
  279.  
  280. void
  281. ShowPlayers (void)
  282. {
  283.   gotoXY (5, ((flag.reverse) ? 23 : 2));
  284.   printz ("%s", (computer == black) ? CP[218] : CP[74]);
  285.   gotoXY (5, ((flag.reverse) ? 2 : 23));
  286.   printz ("%s", (computer == white) ? CP[218] : CP[74]);
  287. }
  288.  
  289. void
  290. ShowDepth (char ch)
  291. {
  292.   gotoXY (TAB, 4);
  293.   printz (CP[53], Sdepth, ch);    /*Depth= %d%c*/
  294.   ClrEoln ();
  295. }
  296.  
  297. void
  298. ShowScore (short score)
  299. {
  300.   gotoXY (TAB, 5);
  301.   printz (CP[104], score);
  302.   ClrEoln ();
  303. }
  304.  
  305. void
  306. ShowMessage (char *s)
  307. {
  308.   gotoXY (TAB, 6);
  309.   printz ("%s", s);
  310.   ClrEoln ();
  311. }
  312.  
  313. void
  314. ClearMessage (void)
  315. {
  316.   gotoXY (TAB, 6);
  317.   ClrEoln ();
  318. }
  319.  
  320. void
  321. ShowCurrentMove (short int pnt, short int f, short int t)
  322. {
  323.   algbr (f, t, false);
  324.   gotoXY (TAB, 7);
  325.   printz ("(%2d) %4s", pnt, mvstr[0]);
  326. }
  327.  
  328. void
  329. ShowHeader (void)
  330. {
  331.   gotoXY (TAB, 2);
  332.   printz (CP[69]);
  333. }
  334.  
  335. void
  336. ShowSidetoMove (void)
  337. {
  338.   gotoXY (TAB, 14);
  339.   printz ("%2d:   %s", 1 + GameCnt / 2, ColorStr[player]);
  340.   ClrEoln ();
  341. }
  342.  
  343. void
  344. ShowPrompt (void)
  345. {
  346.   gotoXY (TAB, 19);
  347.   printz (CP[121]);        /*Your movwe is?*/
  348.   ClrEoln ();
  349. }
  350.  
  351. void
  352. ShowNodeCnt (long int NodeCnt)
  353. {
  354.   gotoXY (TAB, 21);
  355.   printz (CP[90], NodeCnt, (et > 100) ? NodeCnt / (et / 100) : 0);
  356.   ClrEoln ();
  357. }
  358.  
  359. void
  360. ShowResults (short int score, short unsigned int *bstline, char ch)
  361. {
  362.   unsigned char d, ply;
  363.  
  364.   if (flag.post)
  365.     {
  366.       ShowDepth (ch);
  367.       ShowScore (score);
  368.       d = 7;
  369.       for (ply = 1; bstline[ply] > 0; ply++)
  370.     {
  371.       if (ply % 4 == 1)
  372.         {
  373.           gotoXY (TAB, ++d);
  374.           ClrEoln ();
  375.         }
  376.       algbr ((short) bstline[ply] >> 8, (short) bstline[ply] & 0xFF, false);
  377.       printz ("%5s ", mvstr[0]);
  378.     }
  379.       ClrEoln ();
  380.       while (d < 13)
  381.     {
  382.       gotoXY (TAB, ++d);
  383.       ClrEoln ();
  384.     }
  385.     }
  386. }
  387.  
  388. void
  389. SearchStartStuff (short int side)
  390. {
  391.   short i;
  392.  
  393.   signal (SIGINT, TerminateSearch);
  394. #ifdef MSDOS
  395.   side++;            /* shut up the compiler */
  396. #else
  397.   signal (SIGQUIT, TerminateSearch);
  398. #endif /* MSDOS */
  399.   for (i = 4; i < 14; i++)
  400.     {
  401.       gotoXY (TAB, i);
  402.       ClrEoln ();
  403.     }
  404. }
  405.  
  406. void
  407. OutputMove (void)
  408. {
  409.  
  410.   UpdateDisplay (root->f, root->t, 0, (short) root->flags);
  411.   gotoXY (TAB, 17);
  412.   if(flag.illegal){printz(CP[225]);return;}
  413.   printz (CP[84], mvstr[0]);    /*My move is %s*/
  414.   if (flag.beep)
  415.     putchar (7);
  416.   ClrEoln ();
  417.  
  418.   gotoXY (TAB, 24);
  419.   if (root->flags & draw)
  420.     printz (CP[58]);
  421.   else if (root->score == -9999)
  422.     printz (CP[95]);
  423.   else if (root->score == 9998)
  424.     printz (CP[44]);
  425. #ifdef VERYBUGGY
  426.   else if (root->score < -9000)
  427.     printz (CP[96]);
  428.   else if (root->score > 9000)
  429.     printz (CP[45]);
  430. #endif /*VERYBUGGY*/
  431.   ClrEoln ();
  432.   if (flag.post)
  433.     {
  434.       register short h, l, t;
  435.  
  436.       h = TREE;
  437.       l = 0;
  438.       t = TREE >> 1;
  439.       while (l != t)
  440.     {
  441.       if (Tree[t].f || Tree[t].t)
  442.         l = t;
  443.       else
  444.         h = t;
  445.       t = (l + h) >> 1;
  446.     }
  447.  
  448.       ShowNodeCnt (NodeCnt);
  449.       gotoXY (TAB, 22);
  450.       printz (CP[81], t);    /*Max Tree=*/
  451.       ClrEoln ();
  452.     }
  453.   ShowSidetoMove ();
  454. }
  455.  
  456. void
  457. UpdateClocks (void)
  458. {
  459.   short m, s;
  460.  
  461.   m = (short) (et / 6000);
  462.   s = (short) (et - 6000 * (long) m) / 100;
  463.   if (TCflag)
  464.     {
  465.       m = (short) ((TimeControl.clock[player] - et) / 6000);
  466.       s = (short) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  467.     }
  468.   if (m < 0)
  469.     m = 0;
  470.   if (s < 0)
  471.     s = 0;
  472.   if (player == white)
  473.     gotoXY (20, (flag.reverse) ? 2 : 23);
  474.   else
  475.     gotoXY (20, (flag.reverse) ? 23 : 2);
  476.   printz ("%d:%02d   ", m, s);
  477.   if (flag.post)
  478.     ShowNodeCnt (NodeCnt);
  479.   refresh ();
  480. }
  481.  
  482. void
  483. gotoXY (short int x, short int y)
  484. {
  485. #ifdef MSDOS
  486.   putchar (ESC);
  487.   putchar ('[');
  488.   param (y);
  489.   putchar (';');
  490.   param (x);
  491.   putchar ('H');
  492. #else
  493.   move (y - 1, x - 1);
  494. #endif /* MSDOS */
  495. }
  496.  
  497. void
  498. ClrScreen (void)
  499. {
  500. #ifdef MSDOS
  501.   putchar (ESC);
  502.   putchar ('[');
  503.   putchar ('2');
  504.   putchar ('J');
  505. #else
  506.   clear ();
  507. #endif /* MSDOS */
  508.   refresh ();
  509. }
  510.  
  511. void
  512. ClrEoln (void)
  513. {
  514. #ifdef MSDOS
  515.   putchar (ESC);
  516.   putchar ('[');
  517.   putchar ('K');
  518. #else
  519.   clrtoeol ();
  520. #endif /* MSDOS */
  521.   refresh ();
  522. }
  523.  
  524. #ifdef MSDOS
  525. void
  526. param (short n)
  527. {
  528.   if (n >= 10)
  529.     {
  530.       register short d, q;
  531.  
  532.       q = n / 10;
  533.       d = n % 10;
  534.       putchar (q + '0');
  535.       putchar (d + '0');
  536.     }
  537.   else
  538.     putchar (n + '0');
  539. }
  540.  
  541. #endif /* MSDOS */
  542.  
  543. void
  544. DrawPiece (short int sq)
  545. {
  546.   register char x;
  547.  
  548.   if (color[sq] == black)
  549. #if defined(MSDOS) && !defined(SEVENBIT)
  550.     x = '7';            /* print WHITE boldface, */
  551.   else
  552.     x = '1';            /* print BLACK inverted     */
  553.   gotoXY (6 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  554.   printz ("\033[%cm%c\033[0m", x, pxx[board[sq]]);
  555. #else
  556.     x = '*';
  557.   else
  558.     x = ' ';
  559.   gotoXY (5 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  560.   printz ("%c%c ", x, pxx[board[sq]]);
  561. #endif /* MSDOS && !SEVENBIT */
  562. }
  563.  
  564. void
  565. ShowPostnValue (short int sq)
  566.  
  567. /*
  568.  * must have called ExaminePosition() first
  569.  */
  570.  
  571. {
  572.   short score;
  573.  
  574.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  575.   score = ScorePosition (color[sq]);
  576.   if (color[sq] != neutral)
  577.     printz ("%3d ", svalue[sq]);
  578.   else
  579.     printz ("   ");
  580. }
  581.  
  582. void
  583. ShowPostnValues (void)
  584. {
  585.   short sq, score;
  586.  
  587.   ExaminePosition ();
  588.   for (sq = 0; sq < 64; sq++)
  589.     ShowPostnValue (sq);
  590.   score = ScorePosition (opponent);
  591.   gotoXY (TAB, 5);
  592.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  593.  
  594.   ClrEoln ();
  595. }
  596.  
  597. void
  598. UpdateDisplay (short int f, short int t, short int redraw, short int isspec)
  599. {
  600.   short i, sq, z;
  601.  
  602.   if (redraw)
  603.     {
  604.       ShowHeader ();
  605.       ShowPlayers ();
  606.  
  607.       i = 3;
  608.       gotoXY (3, ++i);
  609. #if defined(MSDOS) && !defined(SEVENBIT)
  610.       printz ("\332\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  611.         "\302\304\304\304\304\302\304\304\304\304\302\304\304\304\304" \
  612.           "\302\304\304\304\304\302\304\304\304\304\277");
  613. #else
  614.       printz ("+----+----+----+----+----+----+----+----+");
  615. #endif /* MSDOS && !SEVENBIT */
  616.       while (i < 19)
  617.     {
  618.       gotoXY (1, ++i);
  619.       if (flag.reverse)
  620.         z = (i / 2) - 1;
  621.       else
  622.         z = 10 - (i / 2);
  623. #if defined(MSDOS) && !defined(SEVENBIT)
  624.       printz ("%d \263    \263    \263    \263    \263    \263    " \
  625.           "\263    \263    \263", z);
  626. #else
  627.       printz ("%d |    |    |    |    |    |    |    |    |", z);
  628. #endif /* MSDOS && !SEVENBIT */
  629.       gotoXY (3, ++i);
  630.       if (i < 19)
  631. #if defined(MSDOS) && !defined(SEVENBIT)
  632.         printz ("\303\304\304\304\304\305\304\304\304\304\305\304\304" \
  633.             "\304\304\305\304\304\304\304\305\304\304\304\304\305" \
  634.             "\304\304\304\304\305\304\304\304\304\305\304\304\304" \
  635.             "\304\264");
  636. #else
  637.         printz ("+----+----+----+----+----+----+----+----+");
  638. #endif /* MSDOS && !SEVENBIT */
  639.     }
  640. #if defined(MSDOS) && !defined(SEVENBIT)
  641.       printz ("\300\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  642.         "\301\304\304\304\304\301\304\304\304\304\301\304\304\304\304" \
  643.           "\301\304\304\304\304\301\304\304\304\304\331");
  644. #else
  645.       printz ("+----+----+----+----+----+----+----+----+");
  646. #endif /* MSDOS && !SEVENBIT */
  647.       gotoXY (3, 21);
  648.       if (flag.reverse)
  649.     printz (CP[16]);
  650.       else
  651.     printz (CP[15]);
  652.       for (sq = 0; sq < 64; sq++)
  653.     DrawPiece (sq);
  654.     }
  655.   else
  656.     {
  657.       DrawPiece (f);
  658.       DrawPiece (t);
  659.       if (isspec & cstlmask)
  660.     if (t > f)
  661.       {
  662.         DrawPiece (f + 3);
  663.         DrawPiece (t - 1);
  664.       }
  665.     else
  666.       {
  667.         DrawPiece (f - 4);
  668.         DrawPiece (t + 1);
  669.       }
  670.       else if (isspec & epmask)
  671.     {
  672.       DrawPiece (t - 8);
  673.       DrawPiece (t + 8);
  674.     }
  675.     }
  676.   refresh ();
  677. }
  678.  
  679. extern char *InPtr;
  680. void
  681. skip ()
  682. {
  683.   while (*InPtr != ' ')
  684.     InPtr++;
  685.   while (*InPtr == ' ')
  686.     InPtr++;
  687. }
  688. void
  689. skipb ()
  690. {
  691.   while (*InPtr == ' ')
  692.     InPtr++;
  693. }
  694.  
  695. void
  696. ChangeAlphaWindow (void)
  697. {
  698.   ShowMessage (CP[114]);
  699.   scanz ("%hd", &WAwindow);
  700.   ShowMessage (CP[34]);
  701.   scanz ("%hd", &BAwindow);
  702. }
  703.  
  704. void
  705. ChangeBetaWindow (void)
  706. {
  707.   ShowMessage (CP[115]);
  708.   scanz ("%hd", &WBwindow);
  709.   ShowMessage (CP[35]);
  710.   scanz ("%hd", &BBwindow);
  711. }
  712.  
  713. void
  714. GiveHint (void)
  715. {
  716.   char s[40];
  717.   if (hint)
  718.     {
  719.       algbr ((short) (hint >> 8), (short) (hint & 0xFF), false);
  720.       strcpy (s, CP[198]);    /*try*/
  721.       strcat (s, mvstr[0]);
  722.       ShowMessage (s);
  723.     }
  724.   else
  725.     ShowMessage (CP[223]);
  726. }
  727.  
  728. void
  729. ChangeHashDepth (void)
  730. {
  731.   ShowMessage (CP[163]);
  732.   scanz ("%hd", &HashDepth);
  733.   ShowMessage (CP[82]);
  734.   scanz ("%hd", &HashMoveLimit);
  735. }
  736.  
  737. void
  738. ChangeSearchDepth (void)
  739. {
  740.   ShowMessage (CP[150]);
  741.   scanz ("%hd", &MaxSearchDepth);
  742.   TCflag = !(MaxSearchDepth > 0);
  743. }
  744.  
  745. void
  746. SetContempt (void)
  747. {
  748.   ShowMessage (CP[142]);
  749.   scanz ("%hd", &contempt);
  750. }
  751.  
  752. void
  753. ChangeXwindow (void)
  754. {
  755.   ShowMessage (CP[208]);
  756.   scanz ("%hd", &xwndw);
  757. }
  758.  
  759. void
  760. SelectLevel (char *sx)
  761. {
  762.   int item;
  763.  
  764.   ClrScreen ();
  765.   gotoXY (32, 2);
  766.   printz (CP[41]);
  767.   gotoXY (20, 4);
  768.   printz (CP[18]);
  769.   gotoXY (20, 5);
  770.   printz (CP[19]);
  771.   gotoXY (20, 6);
  772.   printz (CP[20]);
  773.   gotoXY (20, 7);
  774.   printz (CP[21]);
  775.   gotoXY (20, 8);
  776.   printz (CP[22]);
  777.   gotoXY (20, 9);
  778.   printz (CP[23]);
  779.   gotoXY (20, 10);
  780.   printz (CP[24]);
  781.   gotoXY (20, 11);
  782.   printz (CP[25]);
  783.   gotoXY (20, 12);
  784.   printz (CP[26]);
  785.   gotoXY (20, 13);
  786.   printz (CP[27]);
  787.  
  788.   OperatorTime = 0;
  789.   TCmoves = 60;
  790.   TCminutes = 5;
  791.   TCseconds = 0;
  792.  
  793.   gotoXY (20, 17);
  794.   printz (CP[62]);
  795.   refresh ();
  796.   scanz ("%d", &item);
  797.   switch (item)
  798.     {
  799.     case 1:
  800.       TCmoves = 60;
  801.       TCminutes = 5;
  802.       break;
  803.     case 2:
  804.       TCmoves = 60;
  805.       TCminutes = 15;
  806.       break;
  807.     case 3:
  808.       TCmoves = 60;
  809.       TCminutes = 30;
  810.       break;
  811.     case 4:
  812.       TCmoves = 40;
  813.       TCminutes = 30;
  814.       break;
  815.     case 5:
  816.       TCmoves = 40;
  817.       TCminutes = 60;
  818.       break;
  819.     case 6:
  820.       TCmoves = 40;
  821.       TCminutes = 120;
  822.       break;
  823.     case 7:
  824.       TCmoves = 40;
  825.       TCminutes = 240;
  826.       break;
  827.     case 8:
  828.       TCmoves = 1;
  829.       TCminutes = 15;
  830.       break;
  831.     case 9:
  832.       TCmoves = 1;
  833.       TCminutes = 60;
  834.       break;
  835.     case 10:
  836.       TCmoves = 1;
  837.       TCminutes = 600;
  838.       break;
  839.     }
  840.  
  841.   TCflag = (TCmoves > 0);
  842.  
  843.   TimeControl.clock[white] = TimeControl.clock[black] = 0; 
  844.  
  845.   SetTimeControl ();
  846.   ClrScreen ();
  847.   UpdateDisplay (0, 0, 1, 0);
  848. }
  849.  
  850. void
  851. DoDebug (void)
  852. {
  853.   short c, p, sq, tp, tc, tsq, score;
  854.   char s[40];
  855.  
  856.   ExaminePosition ();
  857.   ShowMessage (CP[65]);
  858.   scanz ("%s", s);
  859.   c = neutral;
  860.   if (s[0] == CP[9][0] || s[0] == CP[9][1])    /* w W*/
  861.     c = white;
  862.   if (s[0] == CP[9][2] || s[0] == CP[9][3])    /*b B*/
  863.     c = black;
  864.   for (p = king; p > no_piece; p--)
  865.     if ((s[1] == pxx[p]) || (s[1] == qxx[p]))
  866.       break;
  867.   for (sq = 0; sq < 64; sq++)
  868.     {
  869.       tp = board[sq];
  870.       tc = color[sq];
  871.       board[sq] = p;
  872.       color[sq] = c;
  873.       tsq = PieceList[c][1];
  874.       PieceList[c][1] = sq;
  875.       ShowPostnValue (sq);
  876.       PieceList[c][1] = tsq;
  877.       board[sq] = tp;
  878.       color[sq] = tc;
  879.     }
  880.   score = ScorePosition (opponent);
  881.   gotoXY (TAB, 5);
  882.   printz (CP[103], score, mtl[computer], pscore[computer], mtl[opponent],pscore[opponent]);
  883.  
  884.   ClrEoln ();
  885. }
  886. void
  887. DoTable (short table[64])
  888. {
  889.   short  sq;
  890.   ExaminePosition ();
  891.   for (sq=0;sq<64;sq++){
  892.   gotoXY (4 + 5 * VIR_C (sq), 5 + 2 * (7 - VIR_R (sq)));
  893.   printz ("%3d ", table[sq]);
  894.  
  895. }
  896. }
  897.  
  898.